import request from '@/utils/request'
import type { 
  Notification, 
  CreateNotification, 
  NotificationQuery,
  NotificationStats,
  NotificationList
} from '@/types/api/notification'
import type { API } from '@/types/api/response'

/**
 * 获取通知列表
 * @param params 查询参数
 */
export const getNotificationList = (params: NotificationQuery) => {
  return request.get<API.Response<NotificationList>>('/api/notification/list', { params })
}

/**
 * 获取通知详情
 * @param id 通知ID
 */
export const getNotificationDetail = (id: string) => {
  return request.get<API.Response<Notification>>(`/api/notification/${id}`)
}

/**
 * 创建通知
 * @param data 通知信息
 */
export const createNotification = (data: CreateNotification) => {
  return request.post<API.Response<Notification>>('/api/notification', data)
}

/**
 * 删除通知
 * @param ids 通知ID数组
 */
export const deleteNotifications = (ids: string[]) => {
  return request.delete<API.Response<null>>('/api/notification', { data: { ids } })
}

/**
 * 标记通知为已读
 * @param id 通知ID
 */
export const markNotificationRead = (id: string) => {
  return request.put<API.Response<null>>(`/api/notification/${id}/read`, {})
}

/**
 * 批量标记通知为已读
 * @param ids 通知ID数组
 */
export const markNotificationsRead = (ids: string[]) => {
  return request.put<API.Response<null>>('/api/notification/read', { ids })
}

/**
 * 标记所有通知为已读
 */
export const markAllNotificationsRead = () => {
  return request.put<API.Response<null>>('/api/notification/read-all')
}

/**
 * 清空所有已读通知
 */
export const clearReadNotifications = () => {
  return request.delete<API.Response<null>>('/api/notification/clear-read')
}

/**
 * 获取通知统计数据
 */
export const getNotificationStats = () => {
  return request.get<API.Response<NotificationStats>>('/api/notification/stats')
} 